/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.hutech09.jsale.web.manager.users;

import java.util.List;
import javax.faces.model.ListDataModel;
import org.hutech09.jsale.entity.AccessGroup;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author Nam
 */
public class GroupDataModel extends ListDataModel<AccessGroup> implements SelectableDataModel<AccessGroup> {
    
    public GroupDataModel() {
    }
    
    public GroupDataModel(List<AccessGroup> list) {
        super(list);
    }
    
    @Override
    public Object getRowKey(AccessGroup t) {
        return t.getId();
    }
    
    @Override
    public AccessGroup getRowData(String rowKey) {
        List<AccessGroup> groups = (List<AccessGroup>) getWrappedData();
        for (AccessGroup group : groups) {
            if (group.getId().equals(rowKey)) {
                return group;
            }
        }
        return null;
    }
}